package com.cy.springcloud.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 读取配置中心配置
 * @ClassName: ConfigController
 * @Author: chenyu
 * @Date: 2025/1/8 14:06
 */
@RestController
public class ConfigController {

    @Value("${url}")
    private String url;

    @Autowired
    private Environment env;

    @RequestMapping("/cloud/url")
    public String url() {
        return url;
    }

    @RequestMapping("/cloud/url2")
    public String url2() {
        return env.getProperty("url");
    }
}
